The Building Blocks of a Central Application
Table of Contents
The Application
When you build a Central application, you generally store all of its files in a folder with the same name as the application. That folder contains the following:
- A FLA file with the same name as the folder
- A pod folder
- An agent folder (if applicable)
- An icons folder
- Any other files needed for the application
For example, if the name of your application is SampleApp, you would create a folder on your hard drive called SampleApp and save a FLA file in it called SampleApp.fla (see Figure 1).
Figure 1. Folder structure for SampleApp Central application
For this application, the pod and agent folders each contain an init.as file, and the pod.fla and agent.fla files each contain one line of code to include their respective init.as files. Here's an example of the pod include:
#include "pod/init.as"
I have also created interface.as, which contains all the LCService logic for
the agent—I'll give you more information on this file later. You must
#include it in both the application and the agent. Below is the basic
skeleton of the application code contained in SampleApp.fla.
#include "Interface.as"
// called by Central when app is loaded
onActivate = function(shell, appId, shellId, baseTabIndex, appData) {
vShell = shell;
// agent reference
agentProps = vShell.getAgent();
// pod reference
pods = vShell.getPods();
myPod = pods[0];
}
// called by Central when app is unloaded
onDeactivate = function(shell, appId, shellId, baseTabIndex, appDate) {
// abort all open processes
}
// setting min and max size
getMinimumSize = function() {
var sObj = new Object();
sObj.width = 500;
sObj.height = 500;
return sObj;
}
getMaximumSize = function() {
var sObj = new Object();
sObj.width = 500;
sObj.height = 500;
return sObj;
}
// init the Console
Central.initApplication(this, this);
The code has onActivate and onDeactivate functions, which Central calls automatically. It also has getMinimumSize and getMaximumSize functions, which ensure that the application window stays within specified size limits. In this case, I decided to keep the size the same at all times.